package com.example.ossservice.controller;

import com.example.commonutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.example.ossservice.service.OssService;

@Api(description = "阿里云文件管理")
@RestController
@RequestMapping("/edu_oss/fileoss")
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "文件上传")
    @PostMapping("upload")
    public R uploadOssFile(@RequestParam("file") MultipartFile file){

        String url = ossService.uploadFileAvatar(file);

        return R.ok().data("url",url).message("文件上成功");
    }
}
